﻿using System;
using System.Collections.Generic;
using System.Text;

namespace LearnNet.Entity
{
    /// <summary>
    /// 采集连接地址类
    /// </summary>
    public class Collect_PageGetLinksInfo
    {
        private string name;
        private string url;
        private Encoding pageEncoding;
        private string includeStr;
        private string notInStr;
        private Int32 startNum;
        private Int32 endNum;
        private Int32 addNum;
        private Int32 collectNum;
        private List<String> pageUrls = new List<string>();
        /// <summary>
        /// 采集地址列表
        /// </summary>
        public List<String> PageUrls
        {
            get{return pageUrls;}
        }
        /// <summary>
        /// 采集完成的页数
        /// </summary>
        public Int32 CollectNum
        {
            get { return collectNum; }
            set { collectNum = value; }
        }
        /// <summary>
        /// 返回采集连接地址列表
        /// </summary>
        /// <returns></returns>
        public string GetPageUrlsToString()
        {
            StringBuilder sb = new StringBuilder();
            foreach (string str in PageUrls)
            {
                sb.Append(str);
            }
            return sb.ToString();
        }
        /// <summary>
        /// 不包括
        /// </summary>
        public string NotInStr
        {
            get { return notInStr; }
            set { notInStr = value; }
        }
        /// <summary>
        /// 添加采集页面地址
        /// </summary>
        /// <param name="url"></param>
        public void AddPageUrl(string url)
        {
            if(!pageUrls.Contains(url)){
                pageUrls.Add(url);
            }
        }

        /// <summary>
        /// 移除采集页面地址
        /// </summary>
        /// <param name="url"></param>
        public void RemovePageUrl(string url)
        {
            if (pageUrls.Contains(url))
            {
                for (int i = 0; i < PageUrls.Count; i++)
                {
                    if (PageUrls[i] == url)
                    {
                        PageUrls.RemoveAt(i);
                        break;
                    }
                }


            }
        }

        /// <summary>
        /// 采集名称
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        /// <summary>
        /// 采集连接网页地址
        /// </summary>
        public string Url
        {
            get { return url; }
            set { url = value; }
        }
        /// <summary>
        /// 远程网页地址
        /// </summary>
        public Encoding PageEncoding
        {
            get { return pageEncoding; }
            set { pageEncoding = value; }
        }

        /// <summary>
        /// 获取连接地址中包括字符
        /// </summary>
        public string IncludeStr
        {
            get { return includeStr; }
            set { includeStr = value; }
        }

        /// <summary>
        /// 连接地址中变量起始值
        /// </summary>
        public Int32 StartNum
        {
            get { return startNum; }
            set { startNum = value; }
        }

        /// <summary>
        /// 连接地址中变量结束值
        /// </summary>
        public Int32 EndNum
        {
            get { return endNum; }
            set { endNum = value; }
        }
        /// <summary>
        /// 连接地址中变量递增/递减值
        /// </summary>
        public Int32 AddNum
        {
            get { return addNum; }
            set { addNum = value; }
        }
    }
}
